/**
 * 字段重命名
 * @param arr 数组
 * @param fields_map 需要修改的列名，格式{field_name: new_name }
 */
export default function rename<T>(arr: T[], fields_map: { [field: string]: string; }) {
	return arr.map((it) => {
		const fields = Object.keys(it);
		return fields.reduce((obj, field) => {
			const new_field_name = fields_map[field];
			// const val = it[field];
			obj[new_field_name ? new_field_name : field] = it[field];
			return obj;
		}, {});
	});
}
